-
Notifications
You must be signed in to change notification settings - Fork 188
Extend fuzz tests #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Extend fuzz tests #196
Conversation
Covering more methods for CellUnion and add a rudimentary fuzz test for polygon.
s2/encode_fuzz_test.go
Outdated
if got := p.Area(); got < 0 { | ||
t.Errorf("Area() = %v, want >= 0. Polygon: %v", got, p) | ||
} | ||
// TODO: Test more methods on Polygon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for
- one file with all fuzz tests (or all decoding related fuzz tests)?
- having monolithic
FuzzFoo
tests rather than testing properties independently?
?
http://go/unit-testing-practices?polyglot=go#behavior-testing-examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
That's mostly me being oldschool. In the past, I added fuzz tests to a project that supported earlier go versions that did not yet support fuzz testing, so the fuzz tests needed to be in a seperate file, where a minimum go version was enforced. In this project, we might want to move the fuzz tests to the respective type test, e.g. polygon_test.go. Do you have a preference?
-
Not sure what you mean. The primary thing under test is
Decode
: Will it always create a valid X? The properties we check on the decoded object feel secondary, hence I feel checking them in FuzzDecodeX is approrpiate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Seems better to keep all polygon tests together rather than all fuzz tests together.
- You're not testing a single property. You're testing forall bytes decode doesn't crash && forall polygons area non-negative && more in the future. This seems partially due to the limited set of types supported by fuzzing. Maybe it's also computationally efficient depending on how hard it is for the fuzzer to find valid polygons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Done
- I think this is correct. With every pass, the fuzzer tries to find new interesting examples that execute more code paths. Having a large variety of code paths executed inside the fuzz test is preferable.
Covering more methods for CellUnion and add a rudimentary fuzz test for polygon.